package com.hardroid.workload.ui.widget;

import android.content.Context;
import android.view.LayoutInflater;
import android.widget.Checkable;
import android.widget.TableLayout;
import android.widget.TextView;

import com.hardroid.workload.R;
import com.hardroid.workload.workcalc.Employer;

public class EmployerItemView extends TableLayout implements Checkable{

	public Employer employer;
	public int id;
	
	public TextView idView;
	public TextView nameView;
	public TextView divisionView;
	public TextView unitView;
	public TextView jobView;	
	public TextView genderView;
	public TextView jabatanView;
	
	public boolean checked =false;
	
	public EmployerItemView(Context context, Employer employer, int id) {
		// TODO Auto-generated constructor stub
		super(context);
		this.employer= employer;
		this.id = id;
		LayoutInflater inflater = (LayoutInflater)context.getSystemService(
				  Context.LAYOUT_INFLATER_SERVICE);

		inflater.inflate(R.layout.list_item_employer, this, true);
		
		idView = (TextView) findViewById(R.id.list_item_employer_id);
		nameView = (TextView) findViewById(R.id.list_item_employer_name);
		divisionView = (TextView) findViewById(R.id.list_item_employer_division);
		unitView = (TextView) findViewById(R.id.list_item_employer_unit);
		jobView = (TextView) findViewById(R.id.list_item_employer_job);
				
		setEmployer(employer, id);
	}
	
	public EmployerItemView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}
	
	public void setEmployer (Employer employer, int id){
		this.employer = employer;
		this.id = id;
		idView.setText((id+1)+"");
		nameView.setText(employer.name);
		divisionView.setText(employer.division);
		unitView.setText(employer.unit);
		jobView.setText(employer.job);
			
	}

	@Override
	public boolean isChecked() {
		// TODO Auto-generated method stub
		return checked;
	}

	@Override
	public void setChecked(boolean checked) {
		// TODO Auto-generated method stub
		this.checked = checked;
	}

	@Override
	public void toggle() {
		// TODO Auto-generated method stub
		setChecked(!checked);
	}

}

